/*
 * @Description: 全宗表格组件
 * @Author: Rfan
 * @Date: 2022-01-07 15:20:55
 * @LastEditTime: 2022-06-13 09:49:18
 */

import { useEffect, useState } from 'react';
import { useSortContext } from '../contexts/SortContext';
import SortPane from './SortPane';

const List = () => {
  const { selectAT, selectLevel } = useSortContext();
  // 用于面板标题展示
  const [title, setTitle] = useState<string>('');
  // 传入面板选中的档案类型相关信息
  const [query, setQuery] = useState({});

  useEffect(() => {
    if (selectAT?.atType && selectLevel?.level) {
      setQuery({
        atType: selectAT.atType,
        atCode: selectAT.atCode,
        level: selectLevel.level
      });
      setTitle(selectLevel?.levelName ? `${selectAT?.atName}-${selectLevel?.levelName} ` : '');
    }
  }, [selectAT, selectLevel]);

  return <SortPane title={title} data={query} />;
};

export default List;
